//
//  UILabel+AttributedText.m
//  maintain
//
//  Created by 郑想 on 16/7/23.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "UILabel+AttributedText.h"

@implementation UILabel (AttributedText)

- (void)labelText:(NSString *)text withAttributedText:(NSString *)attributedtext andAttributedColor:(UIColor *)color{
    if (attributedtext == nil){
        self.attributedText = nil;
        return;
    }
    if (color == nil) {
        color = [UIColor blackColor];
    }
    NSString *fullText = [NSString stringWithFormat:@"%@%@",text,attributedtext];
    NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc]initWithString:fullText];
    NSRange attributeTextRange = NSMakeRange(text.length, attributedtext.length);
    [attributedText setAttributes:@{NSForegroundColorAttributeName: color} range:attributeTextRange];
    self.attributedText = attributedText;
}

@end
